// 获取窗口大小
let winWidth = 0
let winHeight = 0
export const findDimensions = () => {
  //获取窗口宽度
  if (window.innerWidth) {
    winWidth = window.innerWidth
  } else if (document.body && document.body.clientWidth) {
    winWidth = document.body.clientWidth
  }

  //获取窗口高度
  if (window.innerHeight) {
    winHeight = window.innerHeight
  } else if (document.body && document.body.clientHeight) {
    winHeight = document.body.clientHeight
  }

  //通过深入Document内部对body进行检测，获取窗口大小
  if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
    winHeight = document.documentElement.clientHeight
    winWidth = document.documentElement.clientWidth
  }
  return winWidth
}

// 字符串前面加空格
/**
 *
 * @param {*} str 需要加空格的字符串
 * @param {*} length str字符串长度
 * @param {*} content 需要在str前面增加的内容
 * @returns
 */
export const strSpace = (str, length, content = '') => {
  return str.padStart(length, content)
}
